﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NewsPublish.Model.Response;
using NewsPublish.Service;

namespace NewsPublish.Web.Areas.Admin.Controllers
{
    [Area("Admin")]
    public class CommentController : Controller
    {
        private CommentService _commentService;

        public CommentController(CommentService commentService)
        {
            this._commentService = commentService;
        }

        /// <summary>
        /// 新闻评论页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            return View(_commentService.GetCommentsList(c => true));
        }

        /// <summary>
        /// 删除一条评论
        /// </summary>
        /// <param name="id">评论ID</param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult DelComment(int id)
        {
            if (id <= 0)
            {
                return Json(new ResponseModel { code = 0, result = "参数有误" });
            }

            return Json(_commentService.DeleteComment(id));
        }


    }
}
